﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Left_Menu.aspx.cs" Inherits="Thksoft.MainAspx.Left_Menu" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>菜单页</title>
    <style type="text/css">
        /*css代码*/
        #menuFavorite {
            width: 50px; /*设置为0 隐藏自定义菜单*/
            height: 25px;
            overflow: hidden; /*隐藏溢出的元素*/
            box-shadow: 0 1px 1px #888,1px 0 1px #ccc;
            position: absolute; /*自定义菜单相对与body元素进行定位*/
        }

        .menuFavorite {
            width: 130px;
            height: 25px;
            line-height: 25px;
            padding: 0 10px;
            background-color: #abcdff;
        }
    </style>
    <script language="javascript" src="/Scripts/Main_Js/SystemMenu.js" type="text/javascript"></script>
    <script type="text/javascript">
        function SetMenuCardNew(menu) {
            location = location;
            var menuContainer = document.getElementById("menuContainer");
            var menuContainer2 = document.getElementById("menuContainer2");
            menuContainer.style.display = "block";
            menuContainer2.style.display = "none";
            //alert(menu);
        }
        function SetMenuCardNew2(menu) {
            var menuContainer = document.getElementById("menuContainer");
            var menuContainer2 = document.getElementById("menuContainer2");
            menuContainer2.style.display = "block";
            menuContainer.style.display = "none";
            //alert("你好：" + menu);
        }

        if (window.attachEvent) {
            window.attachEvent("onload", function () {
                if (window.frameElement && frameElement.menu) {
                    frameElement.style.display = "";
                    frameElement.toggling = false;
                    frameElement.menu.style.display = frameElement.visible;
                    window.detachEvent("onload", this);
                }
            });
        } else if (window.addEventListener) {
            window.addEventListener("load", function () {
                if (window.frameElement && frameElement.menu) {
                    frameElement.style.display = "";
                    frameElement.toggling = false;
                    frameElement.menu.style.display = frameElement.visible;
                    window.removeEventListener("load", this, false);
                }
            }, false);
        }

        //兼容火狐 IE 360
        function getContentSize() {
            var wh = document.body.clientWidth - 28;
            var hi = document.body.clientHeight - 4;

            if (wh > 0 && hi > 0) {
                document.getElementById("menuContainer").style.width = wh;
                document.getElementById("menuContainer").style.height = hi;
                document.getElementById("menuPanel").style.width = document.getElementById("menuPanel").parentNode.clientWidth;
            }
        }

        window.onload = getContentSize;
        window.onresize = getContentSize;
    </script>
</head>
<body style="position: absolute; padding: 1px; margin: 0px; width: 100%; height: 100%; overflow: hidden;"
    scroll="no">
    <form id="form1" runat="server">
        <table border="0" cellpadding="0" cellspacing="0" style="background-image: url('../App_Themes/<%=_System_Skin%>/Images/Menu_table_bg.jpg'); width: 100%; height: 100%">
            <tr>
                <td style="width: 29px; height: 100%;" valign="top">
                    <div id="Menu_Number">
                        <%
                            string menu, span, css, padding;
                            for (int i = 0; i < lstMenu.Count; i++)
                            {
                                menu = "menu_" + (i + 1).ToString();
                                span = "span_" + (i + 1).ToString();
                                css = "";
                                padding = "";
                                if (i == 0)
                                {
                                    if (lstMenu.Count == 1)
                                    {
                                        css = "menucard_Last_checked";
                                        padding = "0";
                                    }
                                    else
                                    {
                                        css = "menucard_First_checked";
                                        padding = "7";
                                    }
                                }
                                else if (i == lstMenu.Count - 1)
                                {
                                    css = "menucard_Last_unchecked";
                                    padding = "0";
                                }
                                else
                                {
                                    css = "menucard_Middle_normal";
                                    padding = "0";
                                }
                        %>
                        <span class="<%=css%>" id="<%=span%>" onclick="SetMenuCardNew('<%=menu%>');">
                            <table width="13" border="0" cellpadding="0" cellspacing="0" style="margin: auto;">
                                <tr>
                                    <td style="padding-top: <%=padding%>px;">
                                        <%=((IList)lstMenu[i])[0]%>
                                    </td>
                                </tr>
                            </table>
                        </span><span class="menucard_Last_unchecked" id="span_2" onclick="SetMenuCardNew2('menu_2');">
                            <table width="13" border="0" cellpadding="0" cellspacing="0" style="margin: auto;">
                                <tr>
                                    <td style="padding-top: 0px;">收藏夹
                                    </td>
                                </tr>
                            </table>
                        </span>
                        <%
                            }
                        %>
                    </div>
                </td>
                <td valign="top">
                    <div class="menuContainer" id="menuContainer" style="width: 165px;">
                        <div class="menuPanel" id="menuPanel" style="width: 145px;">
                            <div id="menu_1">
                                <dx:ASPxNavBar runat="server" ID="NavBar1" />
                            </div>
                            <div id="menu_2" style="display: none">
                                <dx:ASPxNavBar runat="server" ID="NavBar2" />
                            </div>
                            <div id="menu_3" style="display: none">
                                <dx:ASPxNavBar runat="server" ID="NavBar3" />
                            </div>
                            <div id="menu_4" style="display: none">
                                <dx:ASPxNavBar runat="server" ID="NavBar4" />
                            </div>
                            <div id="menu_5" style="display: none">
                                <dx:ASPxNavBar runat="server" ID="NavBar5" />
                            </div>
                            <div id="menu_6" style="display: none">
                                <dx:ASPxNavBar runat="server" ID="NavBar6" />
                            </div>
                        </div>
                    </div>
                    <div class="menuContainer" id="menuContainer2" style="width: 165px; display: none;">
                        <div class="menuPanel" runat="server" id="Div1" style="width: 160px;">
                        </div>
                    </div>
                </td>
            </tr>
        </table>
        <!--自定义右键菜单html代码-->
        <div id="menuFavorite" style="display: none; z-index: 9999;">
            <div id="menu1" class="menuFavorite">收藏</div>
        </div>
    </form>
    <script src="/Scripts/jquery-1.7.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        //禁用浏览器默认鼠标右键事件
        $(document).ready(function () {
            $(document).bind("contextmenu",
                    function () {
                        return false;
                    }
                );
        });

        //禁用浏览器默认鼠标右键事件(没有奏效)
        $(function () {
            $("li.dxnb-item.navMi.dxnb-link").unbind("mousedown").bind("contextmenu", function (e) {
                e.preventDefault();
                return false;
            });

            //收藏链接小窗口地址
            var url = "";

            $("li.dxnb-item.navMi.dxnb-link").unbind("mousedown").bind("mousedown", function (event) {
                //console.log(event.which);
                if (event.which == 3) {
                    url = $(this).find("[target='MenuControl']").attr("href");
                    //console.log(url);

                    //获取右键点击坐标
                    var x = event.clientX;
                    var y = event.clientY;
                    $("#menuFavorite").css({ left: x, top: y }).slideDown(100);

                } else if (event.which == 1) {
                    $("#menuFavorite").slideUp(100);
                    return true;
                }
                else {
                    $("#menuFavorite").slideUp(100);
                    return;
                }
            });

            $(document).bind("click", function (e) {
                if ($(e.target).closest("#menuFavorite").length == 0) {
                    $("#menuFavorite").slideUp(100);
                }
            })

            $("#menu1").mousedown(function (e) {
                console.log(url);
                if (e.which == 1 && url != "" && url != null) {
                    top.MessageBox.Load({
                        Url: '/MainAspx/Favorite.aspx?ID=' + url,
                        Title: '添加收藏',
                        Area: ['500px', '225px']
                    });

                    $("#menuFavorite").slideUp(100);
                }
            });

        })
    </script>
</body>
</html>